<?php
/**
 * 区域相关接口请求参数验证器
 * 发仔<i@fazi.me> 2018-07-09
 */
namespace app\open\validate;

use app\base\validate\BaseValidate;
class AreaValidate extends BaseValidate
{
    //验证
    protected $rule = [
        'area_id' =>  'require|integer',
        'area_pid' =>  'require|integer',
        'area_name' =>  'require',
        'area_code' =>  'require',
        'is_tree' =>  'integer',
        'state' =>  'integer',
        'area_ids' =>  'require',
    ];

    // 默认值
    protected $default = [
        'page' => 1,
        'pagenum' => 20,
        'where_json' => '',
        'fields' => '*',
    ];

    protected $message = [
        'fields.isNotEmpty' => '字段不能为空',
        'where_json.isWhereJson' => '不是合法的json字符串',
    ];

    protected $scene = [
        'list' => [ 'fields', 'where_json'],
        'add' => [
            'area_name','area_code','state','area_pid'
        ],
        'edit' => [
            'area_id', 'area_name','area_code','state','area_pid'
        ],
        'delete' => [ 'area_ids' ],
    ];

}